  <form id="form" method="post" action="{:u('add_user')}" enctype="multipart/form-data">
  <input type="hidden" name="user_id" value="{$user_id}">
            <div class="box box-primary">
                   <label for="message">好友申请说明:</label>
                    <textarea id="message"  required="required" class="form-control" name="message" data-parsley-trigger="keyup" placeholder="请填写内容..."></textarea>
                    </div>
                </div>
                <div class="box-footer">
                    <button type="button" id="sub_add_user"  class="btn btn-primary">提交申请</button>
                </div>
            </div>
        </form>
 <script src="__PUBLIC__/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(function(){
	  var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
		$('#sub_add_user').on('click', function(){
			$.ajax({
			  url:  $('#form').attr('action'),
			  type: 'POST',
			  dataType: 'json',
			  data: $('#form').serialize(),
			  complete: function(xhr, textStatus) {
			    //called when complete
			  },
			  success: function(data) {
			  	if(data.code ==1){
			  		parent.layer.msg(data.msg);
			  		parent.layer.close(index); //执行关闭
			  	}
			  },
			  error: function(xhr, textStatus, errorThrown) {
			    //called when there is an error
			  }
			});
			;
		   
		});
})
</script>